package edu.predatorwars.client.visualization;

import java.awt.Point;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import edu.predatorwars.shared.models.Creature;
import edu.predatorwars.shared.models.Player;
import edu.predatorwars.shared.models.PlayerConnectionInfo;
import edu.predatorwars.shared.models.Buff;

//simple extended creature class to include location on hexgrid...makes stuff more efficient for visualization
public class PlayerExt extends Player {

	//location of the animal on the hexgrid
	private Point playerLocation;

	public PlayerExt(Player player, int x, int y) {
		super(player.getCommInfo(), player.getColor());
		float[] color = player.getColor();
		Creature creature = player.getCreature();
		
		Creature nc;
		this.setCreature( (nc = new Creature(creature.getCreatureType(),new HashMap<Integer, Float>(creature.getBaseStats()))));
		
		nc.addBuffs(creature.getBuffs().toArray(new Buff[0]));
		playerLocation = new Point(x,y);
	}
	
	public PlayerExt(Player player, Point p) {
		super(player.getCommInfo(), player.getColor());
		Creature creature = player.getCreature();
		
		Creature nc;
		this.setCreature( (nc = new Creature(creature.getCreatureType(),new HashMap<Integer, Float>(creature.getBaseStats()))));
		nc.addBuffs(creature.getBuffs().toArray(new Buff[0]));
		
		playerLocation = p;
	}
	
	public void setPlayerLocation(Point loc) {
		playerLocation = loc;
	}
	
	public void setPlayerLocation(int x, int y) {
		playerLocation.x = x;
		playerLocation.y = y;
	}
	
	public Point getPlayerLocation() {
		return playerLocation;
	}


	@Override
	public boolean equals(Object o) {
		if (o instanceof VisPlayer) {
			PlayerConnectionInfo pci1 = ((VisPlayer) o).getPlayer().getCommInfo();
			PlayerConnectionInfo pci2 = this.getCommInfo();
			return pci1.getIpAddress().equals(pci2.getIpAddress()) && pci1.getName().equals(pci2.getName());
		}
		else {
			return super.equals(o);
		}
	}
}